﻿using NJabber.Stream.Elements;

namespace NJabber.Client.StanzaFactories
{
    public class MessageStanzaFactory : StanzaFactory<MessageParameters>, IMessageStanzaFactory
    {
        public Stanza CreatePersonalMessage(JID receiverId, string subject, string text)
        {
            return CreateMessageStanza(MessageStanzaType.Chat, receiverId, subject, text);  
        }

        public Stanza CreateGroupMessage(JID receiverId, string subject, string text)
        {
            return CreateMessageStanza(MessageStanzaType.GroupChat, receiverId, subject, text);
        }

        public Stanza CreateHeadlineMessage(JID receiverId, string subject, string text)
        {
            return CreateMessageStanza(MessageStanzaType.Headline, receiverId, subject, text);
        }

        public Stanza CreateStandaloneMessage(JID receiverId, string subject, string text)
        {
            return CreateMessageStanza(MessageStanzaType.Normal, receiverId, subject, text);
        }

        private Stanza CreateMessageStanza(string stanzaType, JID receiverId, string subject, string text)
        {
            MessageStanza stanza = CreateStanza<MessageStanza>();
            stanza.Type = stanzaType;
            stanza.To = receiverId;
            stanza.Subject = subject;
            stanza.Body = text;
            return stanza;
        }

        public Stanza CreateMessage(MessageParameters parameters)
        {
            throw new System.NotImplementedException();
        }
    }
}
